package com.tyk.bookstore.back.product.util;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tyk.bookstore.back.common.core.model.type.BinVo;
import com.tyk.bookstore.back.product.manager.excel.model.AuthorExcelVo;
import com.tyk.bookstore.back.product.manager.excel.model.BookExcelVo;
import com.tyk.bookstore.back.product.manager.excel.model.PublisherExcelVo;
import com.tyk.bookstore.back.product.model.dto.BookSuggestionDto;
import com.tyk.bookstore.back.product.model.dto.ClazzNestDto;
import com.tyk.bookstore.back.product.model.entity.*;
import com.tyk.bookstore.back.product.model.query.*;
import com.tyk.bookstore.back.product.model.vo.*;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;

import java.util.List;

@Mapper(componentModel = "spring")
public interface MapStructProduct {

    @Mapping(target = "price", source = "b.price")
    BookVo toBookVo(BookDo b, BookStatisticDo bs);

    BookPageVo toBookPageVo(Page<BookDo> page);

    @Mappings({
            @Mapping(target = "clazzFullName", ignore = true)
    })
    BookPageVo.Book toBookPageVo$Book(BookDo bookDo);

    @Mappings({
            @Mapping(target = "id", ignore = true),
            @Mapping(target = "bookNo", ignore = true),
            @Mapping(target = "createTime", ignore = true),
            @Mapping(target = "updateTime", ignore = true)
    })
    BookDo toBookDo(BookAddQuery query);

    @Mappings({
            @Mapping(target = "bookNo", ignore = true),
            @Mapping(target = "createTime", ignore = true),
            @Mapping(target = "updateTime", ignore = true)
    })
    BookDo toBookDo(BookUpdateQuery query);

    AuthorVo toAuthorVo(AuthorDo author);

    AuthorPageVo toAuthorPageVo(Page<AuthorDo> page);

    @Mappings({
            @Mapping(target = "id", ignore = true)
    })
    AuthorDo toAuthorDo(AuthorAddQuery query);

    AuthorDo toAuthorDo(AuthorUpdateQuery query);

    PublisherVo toPublisherVo(PublisherDo publisher);

    PublisherPageVo toPublisherPageVo(Page<PublisherDo> page);

    @Mappings({
            @Mapping(target = "id", ignore = true)
    })
    PublisherDo toPublisherDo(PublisherAddQuery query);

    PublisherDo toPublisherDo(PublisherUpdateQuery query);

    @Mappings({
            @Mapping(target = "children", ignore = true)
    })
    ClazzNestVo toClazzNestVo(ClazzNestDto clazzNestDto);

    List<BookSuggestionVo> toBookSuggestionVoList(List<BookSuggestionDto> dtoList);

    List<BookStatisticDo> toBookStatisticDoList(List<Statistic4TaskUpdateQuery> qs);

    ClazzVo toClassificationVo(ClazzDo cd);

    ClazzPageVo toClassificationPageVo(Page<ClazzDo> page);

    ClazzDo toClassificationDo(ClazzAddQuery query);

    ClazzDo toClassificationDo(ClazzUpdateQuery query);

    List<ClazzListVo> toClazzListVo(List<ClazzDo> doList);

    BookStatisticVo toBookStatisticVo(BookStatisticDo bookStatistic);

    BookStatisticPageVo toBookStatisticPageVo(Page<BookStatisticDo> page);

    BookStatisticDo toBookStatisticDo(BookStatisticAddQuery query);

    BookStatisticDo toBookStatisticDo(BookStatisticUpdateQuery query);

    List<BookVo.ClazzNameVo> toBookVo$ClazzNameVoList(List<BinVo> binVoList);

    @Mappings({
            @Mapping(target = "clazzId", source = "id"),
            @Mapping(target = "clazzName", source = "value")
    })
    BookVo.ClazzNameVo toBookVo$ClazzNameVo(BinVo binVo);

    @Mappings({
            @Mapping(target = "price",source = "bk.price")
    })
    BookExcelVo toBookExcelVo(BookDo bk, BookStatisticDo bs);


    List<AuthorExcelVo> toAuthorExcelVoList(List<AuthorDo> doList);


    List<AuthorDo> toAuthorDoList(List<AuthorExcelVo> authorList);

    @Mappings({
            @Mapping(target = "id", ignore = true),
            @Mapping(target = "createTime", ignore = true),
            @Mapping(target = "updateTime", ignore = true),
    })
    AuthorDo toAuthorDo(AuthorExcelVo vo);

    List<PublisherExcelVo> toPublisherExcelVoList(List<PublisherDo> doList);

    List<PublisherDo> toPublisherDoList(List<PublisherExcelVo> publisherList);

    @Mappings({
            @Mapping(target = "id", ignore = true),
            @Mapping(target = "createTime", ignore = true),
            @Mapping(target = "updateTime", ignore = true),
    })
    PublisherDo toPublisherDo(PublisherExcelVo publisher);

    @Mappings({
            @Mapping(target = "id", ignore = true),
            @Mapping(target = "bookNo", ignore = true),
            @Mapping(target = "state", ignore = true),
            @Mapping(target = "createTime", ignore = true),
            @Mapping(target = "updateTime", ignore = true),
    })
    BookDo toBookDo(BookExcelVo bookExcelVo);

    List<BookDo> toBookDoList(List<BookExcelVo> bookList);
}
